package com.starleague.battletech.rules;

import java.util.Random;

import javax.inject.Inject;
import javax.inject.Singleton;

import com.google.common.base.Preconditions;

@Singleton
public class BattletechDice
{
    private static final int SIDES = 6;

    private final Random random;

    @Inject
    public BattletechDice()
    {
        this.random = new Random();
    }

    public BattletechDice(int randomSeed)
    {
        this.random = new Random(randomSeed);
    }

    public int roll(int numDice)
    {
        Preconditions.checkArgument(numDice > 0, "Invalid number of Dice: " + numDice);

        int result = 0;
        for (int i = 0; i < numDice; ++i)
            result += this.random.nextInt(SIDES) + 1;
        return result;
    }

    // public int rollPercent()
    // {
    // return roll(1) * 10 + roll(1);
    // }
}
